﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/h-ui.admin/css/style.css" />
<![endif]-->
<script type="text/javascript" src="/js/vue/vue.min.js"></script>
<link rel="stylesheet" href="/js/laypage/skin/laypage.css">
<script type="text/javascript" src="/js/laypage/laypage.js"></script>
<link rel="stylesheet" href="/lib/layui/css/layui.css"  media="all">
	<title>添加收支项目</title>
</head>
<body>
<div class="page-container">
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="c-red">*</span>账目类型</label>
			<div class="layui-input-block">
				<input type="text" id="fcType" name="fcType" lay-verify="fcType" autocomplete="off" placeholder="请输入账目类型" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">收支类别</label>
			<div class="layui-input-block">
				<select name="fcSort" id="fcSort" lay-filter="aihao">
					<option value="收入">收入</option>
					<option value="支出" selected="">支出</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">备注</label>
			<div class="layui-input-block">
				<textarea placeholder="说点什么..." cols="5" rows="3" id="fcRemark" class="layui-textarea"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" id="saveBtn" lay-submit="" lay-filter="demo1">提交</button>
				<button type="reset" id="cancelBtn" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //自定义验证规则
        form.verify({
            fcType: function(value){
                if(value.length < 2){
                    return '账目类型至少得2个字符啊';
                }
                var check="";
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "/billManagement/finance-classify/checkFcExit",
                    async:false,//ajax改成同步提交
                    data: {
                        "fcType": value,
                    },

                    success:function (msg) {
                        /*alert("是否存在？"+msg);*/
						if (msg == true){
						   check= "该账目类型名已存在！";
						}
                    }
				});
				return check;
            }
        });

        //监听提交
        form.on('submit(demo1)', function(){
            $.ajax({
                type: "GET",
                dataType: "json",
                url: "/billManagement/finance-classify/insertFc",
                data: {
                    "fcType": $("#fcType").val(),
                    "fcSort": $("#fcSort").val(),
                    "fcRemark":$("#fcRemark").val(),
                },
                success: function(msg){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.getFcPageList();
                    parent.layer.close(index);
                }
            });
            return false;
		});
    });
</script>
</body>
</html>